﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdHatchPatternManager : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdHatchPatternManager(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdHatchPatternManager_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdHatchPatternManager obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdHatchPatternManager()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdHatchPatternManager(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdHatchPatternManager cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdHatchPatternManager_cast(OdRxObject.getCPtr(pObj));
			OdHatchPatternManager result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdHatchPatternManager)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdHatchPatternManager)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdHatchPatternManager)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdHatchPatternManager_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdHatchPatternManager_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdHatchPatternManager_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdHatchPatternManager createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdHatchPatternManager_createObject();
			OdHatchPatternManager result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdHatchPatternManager)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdHatchPatternManager)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdHatchPatternManager)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void setApplicationService(OdDbHostAppServices pServices)
		{
			TD_DbPINVOKE.OdHatchPatternManager_setApplicationService(this.swigCPtr, OdDbHostAppServices.getCPtr(pServices));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdResult retrievePattern(OdDbHatch.HatchPatternType hatchPatternType, string hatchPatternName, MeasurementValue measurementValue, OdHatchPattern hatchPattern)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdHatchPatternManager_retrievePattern(this.swigCPtr, (int)hatchPatternType, hatchPatternName, (int)measurementValue, OdHatchPattern.getCPtr(hatchPattern));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void appendPattern(OdDbHatch.HatchPatternType hatchPatternType, string hatchPatternName, OdHatchPattern hatchPattern, MeasurementValue measurementValue)
		{
			TD_DbPINVOKE.OdHatchPatternManager_appendPattern__SWIG_0(this.swigCPtr, (int)hatchPatternType, hatchPatternName, OdHatchPattern.getCPtr(hatchPattern), (int)measurementValue);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void appendPattern(OdDbHatch.HatchPatternType hatchPatternType, string hatchPatternName, OdHatchPattern hatchPattern)
		{
			TD_DbPINVOKE.OdHatchPatternManager_appendPattern__SWIG_1(this.swigCPtr, (int)hatchPatternType, hatchPatternName, OdHatchPattern.getCPtr(hatchPattern));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdResult retrievePatternList(OdDbHatch.HatchPatternType hatchPatternType, MeasurementValue measurementValue, OdStringArray patternNames)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdHatchPatternManager_retrievePatternList(this.swigCPtr, (int)hatchPatternType, (int)measurementValue, OdStringArray.getCPtr(patternNames));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void reset()
		{
			TD_DbPINVOKE.OdHatchPatternManager_reset(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
